/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 artifact_effect.h

	$Header: /heroes4/artifact_effect.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( ARTIFACT_EFFECT_H_INCLUDED )
#define ARTIFACT_EFFECT_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#pragma warning( disable: 4786 )

#include <iosfwd>
#include "artifact_effect_ptr.h"
#include "artifact_effect_type.h"

class t_artifact_effect_visitor;

// ----------------------------------------------------------------------
// class for artifact effects with 1 integer or no parameters
// ----------------------------------------------------------------------
class t_artifact_effect : public t_counted_object
{
public:
	virtual ~t_artifact_effect();

	virtual bool					accept( t_artifact_effect_visitor& visitor );
	virtual t_artifact_effect*		clone() const = 0;
	int								get_amount() const;
	virtual t_artifact_effect_type	get_effect() const = 0;
	virtual int                     get_level() const;
	t_artifact_target				get_target() const;
	bool							is_legal( t_artifact_target target ) const;
	virtual bool					read( std::streambuf& buffer );
	void							set_amount( int arg );
	void							set_target( t_artifact_target target );
	virtual bool					write( std::streambuf& buffer ) const;
protected:
	t_artifact_effect();
	
	void init( t_artifact_target target, int amount = 0 );

	t_artifact_target	   m_target;
	int					   m_amount; // may be a simple number or a percentage, depending on type.
};

inline t_artifact_effect::t_artifact_effect()
{
	m_target = k_artifact_target_hero;
	m_amount = 0;
}

inline void t_artifact_effect::init( t_artifact_target target, int amount ) 
{
	m_target = target;
	m_amount = amount;
}

inline int t_artifact_effect::get_amount() const
{
	return m_amount;
}

inline t_artifact_target t_artifact_effect::get_target() const
{
	return m_target;
}

inline bool t_artifact_effect::is_legal( t_artifact_target target ) const
{
	return ::is_legal( get_effect(), target );
}

inline void	t_artifact_effect::set_amount( int arg )
{
	m_amount = arg;
}

inline void t_artifact_effect::set_target( t_artifact_target target )
{
	m_target = target;
}


// ----------------------------------------------------------------------
// functions
// ----------------------------------------------------------------------
t_artifact_effect_ptr create_effect( t_artifact_effect_type type );

#endif // ARTIFACT_EFFECT_H_INCLUDED
